/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


var xhr;
//alert("llegue al js profesores");
function buscarDetalle(){
    
    if(window.ActiveXObject){        
        xhr = new ActiveXObject("Microsoft.XMLHttp");
    }
    else if(window.XMLHttpRequest || (typeof XMLHttpRequest)!= undefined){
        xhr = new XMLHttpRequest();
    }
    else{
        alert("su navegador no soporta AJAX");
        return;
    }

}
//------------------------------------------------------------------------------
function cajasmateriapre(){
    buscarDetalle();
    var pre = document.getElementById("pre").checked;
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
//    alert("valoor del check"+pre);
    xhr.open("GET","../svlprofesores?pre="+pre+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmateria;
    xhr.send(null);
}
function imprimircajasmateria(){
    if(xhr.readyState == 4){
        document.getElementById("checkpre").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------
function cajasmateriapri(){
    buscarDetalle();
    var pri = document.getElementById("pri").checked;
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
    //    alert("valoor del check"+pri);
    xhr.open("GET","../svlprofesorespri?pri="+pri+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmateriapri;
    xhr.send(null);
}
function imprimircajasmateriapri(){
    if(xhr.readyState == 4){
        document.getElementById("checkpri").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------
function cajasmateriasec(){
    buscarDetalle();
    var sec = document.getElementById("sec").checked;
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
    //    alert("valoor del check"+sec);
    xhr.open("GET","../svlprofesoressec?sec="+sec+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmateriasec;
    xhr.send(null);
}
function imprimircajasmateriasec(){
    if(xhr.readyState == 4){
        document.getElementById("checksec").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------
function cajasmateriabag(){
    buscarDetalle();
    var bag = document.getElementById("bag").checked;
//    alert("valoor del check"+bag);
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
    xhr.open("GET","../svlprofesoresbag?bag="+bag+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmateriabag;
    xhr.send(null);
}
function imprimircajasmateriabag(){
    if(xhr.readyState == 4){
        document.getElementById("checkbag").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------

function cajasmateriatec(){
    buscarDetalle();
    var tec = document.getElementById("tec").checked;
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
    //    alert("valoor del check"+sec);
    xhr.open("GET","../svlprofesorestec?tec="+tec+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmateriatec;
    xhr.send(null);
}
function imprimircajasmateriatec(){
    if(xhr.readyState == 4){
        document.getElementById("checktec").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------
function cajasmaterialic(){
    buscarDetalle();
    var lic = document.getElementById("lic").checked;
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
    //    alert("valoor del check"+sec);
    xhr.open("GET","../svlprofesoreslic?lic="+lic+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmaterialic;
    xhr.send(null);
}
function imprimircajasmaterialic(){
    if(xhr.readyState == 4){
        document.getElementById("checklic").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------
function cajasmateriamas(){
    buscarDetalle();
    var mas = document.getElementById("mas").checked;
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
    //    alert("valoor del check"+sec);
    xhr.open("GET","../svlprofesoresmas?mas="+mas+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmateriamas;
    xhr.send(null);
}
function imprimircajasmateriamas(){
    if(xhr.readyState == 4){
        document.getElementById("checkmas").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------
function cajasmateriadoc(){
    buscarDetalle();
    var doc = document.getElementById("doc").checked;
    var hiden = document.getElementById("idprofesor").value;
//    alert("idprofesor"+hiden);
    //    alert("valoor del check"+sec);
    xhr.open("GET","../svlprofesoresdoc?doc="+doc+"&hiden="+hiden,true);
    xhr.onreadystatechange = imprimircajasmateriadoc;
    xhr.send(null);
}
function imprimircajasmateriadoc(){
    if(xhr.readyState == 4){
        document.getElementById("checkdoc").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------






function checkprimerbag(){
    buscarDetalle();
    xhr.open("GET","../primerbagchecks",true);
    xhr.onreadystatechange = imprimecheksprimerbag;
    xhr.send(null);
}
function imprimecheksprimerbag(){

    if(xhr.readyState == 4){
        if(xhr.status == 200)    {
            document.getElementById("primerbag").innerHTML=xhr.responseText;
            checksegundobag();
        }
    }
}
//------------------------------------------------------------------------------
function checksegundobag(){
    xhr.open("GET","../segundobagchecks",true);
    xhr.onreadystatechange = imprimechekssegundobag;
    xhr.send(null);
}
function imprimechekssegundobag(){
    if(xhr.readyState == 4){
        setTimeout("", 500);
        document.getElementById("segundooobab").innerHTML=xhr.responseText;
        checktercerobag();
    }
}
//------------------------------------------------------------------------------
function checktercerobag(){
    xhr.open("GET","../tercerobagchecks",true);
    xhr.onreadystatechange = imprimechekstercerobag;
    xhr.send(null);
}
function imprimechekstercerobag(){
    if(xhr.readyState == 4){
        setTimeout("", 500);
        document.getElementById("tercerobab").innerHTML=xhr.responseText;
        checkcuartobag();
    }
}
//------------------------------------------------------------------------------
function checkcuartobag(){
    xhr.open("GET","../cuartobagchecks",true);
    xhr.onreadystatechange = imprimechekscuartobag;
    xhr.send(null);
}
function imprimechekscuartobag(){
    if(xhr.readyState == 4){
        setTimeout("", 500);
        document.getElementById("cuartobab").innerHTML=xhr.responseText;
        checkquintobag();
    }
}
//------------------------------------------------------------------------------
function checkquintobag(){
    xhr.open("GET","../quintobagchecks",true);
    xhr.onreadystatechange = imprimecheksquintobag;
    xhr.send(null);
}
function imprimecheksquintobag(){
    if(xhr.readyState == 4){
        setTimeout("", 500);
        document.getElementById("quintobab").innerHTML=xhr.responseText;
        checksextobag();
    }
}
//------------------------------------------------------------------------------
function checksextobag(){
    xhr.open("GET","../sextobagchecks",true);
    xhr.onreadystatechange = imprimechekssextobag;
    xhr.send(null);
}
function imprimechekssextobag(){
    if(xhr.readyState == 4){
        setTimeout("", 500);
        document.getElementById("sextobab").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------


function agregarprof(){
    //    alert("dddddddddddd");
    buscarDetalle();
    //        alert("llegue a agregarprof");
    var nombreprof = document.getElementById("nombreprof").value;
    //        alert("nombre del profesor"+nombreprof);
    var appprofesor = document.getElementById("appprof").value;
    //        alert("app profesor"+appprofesor);
    var apmprofesor = document.getElementById("apmprof").value;
    //        alert("apm profesor "+apmprofesor);
    
    xhr.open("POST","../agregarmateriaprof",true);
    //    alert("open");
    xhr.onreadystatechange = agregaprofmat;
    //    alert("onreadystatechange");
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    //    alert("setRequestHeader");
    xhr.send("nomprof="+nombreprof+"&appprof="+appprofesor+"&apmprof="+apmprofesor);
    alert("se dio de alta el profesor "+nombreprof+" "+appprofesor+" "+apmprofesor);
}
function agregaprofmat(){
    //    alert(agregarprofmat);
    if(xhr.readyState == 4){
        if(xhr.status == 200){
            //        alert("readyState");

            document.getElementById("imprimenombreprof").innerHTML=xhr.responseText;
            formularioniveles12();
        }
    }

//formularioniveles();
}
//------------------------------------------------------------------------------

function formularioniveles12(){
    xhr.open("GET","../todasmaterias",true);
    xhr.onreadystatechange = total9;
    xhr.send(null);
}
function total9(){
    if(xhr.readyState == 4){

        document.getElementById("materiaschek").innerHTML=xhr.responseText;
    }
}

//------------------------------------------------------------------------------


function formularioniveles(){
    xhr.open("GET","../nuevoformulario",true);
    xhr.onreadystatechange = imprimechekssextobag;
    xhr.send(null);
}
function imprimechekssextobag(){
    if(xhr.readyState == 4){
        setTimeout("", 500);
        document.getElementById("sextobab").innerHTML=xhr.responseText;
    }
}

//------------------------------------------------------------------------------

function agregarmateriaprofesores(id){
//    alert("id materia"+id);
    var idprofff = document.getElementById("profidid").value;
//    alert ("idprofff"+idprofff);
        
    xhr.open("POST","../agregarmateriasprofesores",true);
//    alert("open");
    xhr.onreadystatechange = insert12;
//    alert("onreadystatechange");
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//    alert("setRequestHeader");
    xhr.send("idmateria="+id+"&idprofesor="+idprofff);
//    alert("vientos");
    
}
function insert12(){
    if(xhr.readyState == 4){
        document.getElementById("materiasagregadas").innerHTML=xhr.responseText;
    }
}
//------------------------------------------------------------------------------